# File: buildcfg/modulescfg.mk

# 选择启用哪些模块
# ---------------------------------------------------------------------------
MODULES_FUNC_TIME    := y
MODULES_FUNC_DEBUG   := y
MODULES_FUNC_VERSION := y
MODULES_FUNC_FILE    := y
  
# 确定需要添加 -D 选项的 item
# ---------------------------------------------------------------------------
ifeq ($(MODULES_FUNC_TIME), y)
DEF_ITEMS            += FUNC_TIME
endif

ifeq ($(MODULES_FUNC_DEBUG), y)
DEF_ITEMS            += FUNC_DEBUG
endif

ifeq ($(MODULES_FUNC_VERSION), y)
DEF_ITEMS            += FUNC_VERSION
endif

ifeq ($(MODULES_FUNC_FILE), y)
DEF_ITEMS            += FUNC_FILE # 这里不能直接用FILE，可能会跟库中产生冲突
endif

# git版本号处理
# ---------------------------------------------------------------------------
GIT_REPO_TEST = $(shell if git rev-parse --is-inside-work-tree >/dev/null 2>&1; \
					then echo "true"; \
					else echo "false"; fi ;)

ifeq ($(GIT_REPO_TEST),true)
GIT_SHA = $(shell git rev-parse --short HEAD | awk 'NR==1')
GIT_SEQ = $(shell git rev-list HEAD | wc -l)
GIT_VER_INFO = $(GIT_SHA)-$(GIT_SEQ)
# GIT_SVR_PATH = $(shell git remote -v | awk 'NR==1' | sed 's/[()]//g' | sed 's/\t/ /g' |cut -d " " -f2)
endif

ifneq ($(GIT_VER_INFO),)
  GIT_DEF_ITEMS += GIT_VERSION=\"$(GIT_VER_INFO)\"
else
  GIT_DEF_ITEMS += GIT_VERSION=\"unknown\"
endif

ifneq ($(GIT_SVR_PATH),)
  GIT_DEF_ITEMS += GIT_PATH=\"$(GIT_SVR_PATH)\"
else
  GIT_DEF_ITEMS += GIT_PATH=\"unknown\"
endif

# 添加 -D 前缀，生成 -Dxxx 选项
# ---------------------------------------------------------------------------
DEFFLAGSS          += $(addprefix -D, $(DEF_ITEMS))
GITFLAGS           += $(addprefix -D, $(GIT_DEF_ITEMS))
